﻿<v:AbstractVariableEditorControl x:Class="Deployment.Data.SQL.Variable.UI.SQLConnectionVariableControl2"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:v="clr-namespace:Deployment.Data.Variable;assembly=Deployment.Data"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <v:AbstractVariableEditorControl.Resources>
        <BooleanToVisibilityConverter x:Key="boolToVisConveter"/>
    </v:AbstractVariableEditorControl.Resources>
    <DockPanel LastChildFill="True" x:Name="DockPanel" Margin="8">
        <DockPanel.Style>
            <Style>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=v:AbstractVariableEditorControl}, Path=Variable}"
                                 Value="{x:Null}">
                        <Setter Property="DockPanel.IsEnabled" Value="False"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </DockPanel.Style>
        <Grid DockPanel.Dock="Top"
                      Width="{Binding ElementName=GroupDockPanel, Path=ActualWidth}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Label Grid.Row="0" Grid.Column="0"
                           Content="Variable name:"
                           VerticalAlignment="Center"
                           Margin="2"
                           Padding="2"/>
            <ComboBox Grid.Row="0" Grid.Column="1"
                              x:Name="cbo_VariableName" 
                              IsEditable="True" 
                              VerticalAlignment="Center"
                              Margin="2"
                              Padding="2"
                              ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=v:AbstractVariableEditorControl}, Path=Variables}"
                              Text="{Binding RelativeSource={RelativeSource AncestorType=v:AbstractVariableEditorControl}, Path=Variable.EnvironmentName}"
                              DisplayMemberPath="Name"/>

            <Label Grid.Row="1" Grid.Column="0"
                           Content="Environment:"
                           VerticalAlignment="Center"
                           Margin="2"
                           Padding="2"/>
            <ComboBox Grid.Row="1" Grid.Column="1"
                              x:Name="cbo_EnvironmentName"
                              IsEditable="True"
                              VerticalAlignment="Center"
                              Margin="2"
                              Padding="2"
                              ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=v:AbstractVariableEditorControl}, Path=Environments}"
                              DisplayMemberPath="Name"
                              Text="{Binding EnvironmentName}">

                <!--I want to add something here so that
                        when the value in text is a RegEx.Match to any item
                        in the dropdown list that items background or foreground 
                        is changed you have a visual indicator to a match-->
            </ComboBox>

            <Label Grid.Row="2" Grid.Column="0"
                   Content="Connection name:"
                   VerticalAlignment="Center"
                   Margin="2"
                   Padding="2"/>
            <ComboBox Grid.Row="2" Grid.Column="1"
                      VerticalAlignment="Center"
                      Text="{Binding RelativeSource={RelativeSource AncestorType=v:AbstractVariableEditorControl}, Path=Variable.Extra}"
                      Margin="2"
                      Padding="2"
                      IsEditable="True"/>
            <!--<TextBox Grid.Row="2" Grid.Column="1"
                     VerticalAlignment="Center"
                     Text="{Binding RelativeSource={RelativeSource AncestorType=v:AbstractVariableEditorControl}, Path=Variable.Value}"
                     Margin="2"
                     Padding="2"/>-->

            <Label Grid.Row="3" Grid.Column="0"
                           Content="Value:"
                           VerticalAlignment="Center"
                           Margin="2"
                           Padding="2"/>
            <TextBox Grid.Row="3" Grid.Column="1"
                     VerticalAlignment="Center"
                     Margin="2"
                     Padding="2"
                     Text="{Binding RelativeSource={RelativeSource AncestorType=v:AbstractVariableEditorControl}, Path=Variable.Value}"
                     />
        </Grid>
        <CheckBox x:Name="chb_ContentOk" Visibility="Collapsed"
                  IsChecked="{Binding isContentOk, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
                  Checked="chb_ContentOk_Checked"/>
    </DockPanel>
</v:AbstractVariableEditorControl>
